package codelib.s2sh.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import codelib.s2sh.dao.IUserDao;
import codelib.s2sh.dao.model.User;

public class UserDaoImpl extends HibernateDaoSupport implements IUserDao {

	// 判断用户是否存在

	@Override
	public List<User> findByUserId(String userId) {
		@SuppressWarnings("unchecked")
		List<User> list = getHibernateTemplate().find(
				"from User where userId = ?", userId);
		return list;
	}

	// 判断用户密码是否正确
	@Override
	public boolean checkPassword(String userId, String passwd) {
		@SuppressWarnings("unchecked")
		List<User> list = getHibernateTemplate().find(
				"from User where userId = ? and passwd = ?",
				new Object[] { userId, passwd });
		if (list == null || list.size() == 0)
			return false;
		else
			return true;
	}
}
